<?php
class College_model extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    /**
     * Get All College Name
     * @return mixed
     */
    function getAll() {
        $query = $this->db->get('pr_college');
        return $query->result_array();
    }

    /**
     * Create a new college
     */
    function insert() {
        $this->name = $this->input->post('name');
        $this->db->insert('pr_college', $this);
    }

    /**
     * Select a specific college & get its information
     * @param $id
     * @return mixed
     */
    function select($id) {
        $query = $this->db->get_where('pr_college',array('id' => $id));
        return $query->row_array();
    }

    /**
     * Update the information of specific college
     */
    function edit() {
        $this->name = $this->input->post('name');
        $id = $this->input->get('id');
        $this->db->update('pr_college', $this, array('id' => $id));
    }

    /**
     * Delete the specific college
     */
    function delete() {
        $id = $this->input->get('id');
        $this->db->delete('pr_college', array('id' => $id));
    }
}